var $table = $('#announcement_list');

//初始化公告
$(function () {
    announcementTableInit();
    getNewsList();
    $('select').selectpicker({
        sanitize: true,
        size: 10,
        width:100,
        style:'selRadius'
    });
    // 轮播图
    var swiper = new Swiper('.swiper-container', {
        spaceBetween: 30,
        effect: 'fade',
        loop: true,
        autoplay: true,
        delay: 300,
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
        },
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },
    });
    // 处理页面有滚动条时，页面右侧边距缩窄
    if (window.innerWidth !== $(document).width()) {
        $('.container-fluid').addClass('p-scroll');
    }
    // 模态框显示时模糊背景
    $('.modal').on('show.bs.modal', function (e) {
        $('.container-fluid').addClass('modal-blur');
    }).on('hidden.bs.modal', function (e) {
        $('.container-fluid').removeClass('modal-blur');
    });
    $('#nothing').css('display', 'none');
    $('#browsData input').on('click', function () {
        var dateType = $(this).val();
        browsDataFun(dateType);
    });
    browsDataFun('');
    //getForgetRemind();
    ourCompanyInit();
});

//遗忘提醒
function getForgetRemind(){
    $.ajax({
        url: "/forgetRemind/forgetRemindStatistics",
        type: "get",
        dataType: "json",
        success: function (data){
            if (data.code = '000000'){
                // $(".text-right")[0].append(data.data.moreThan7Days);
                // $(".text-right")[1].append(data.data.moreThan15Days);
                // $(".text-right")[2].append(data.data.moreThan30Days);
                // $(".text-right")[3].append(data.data.moreThan3Months);
                // $(".text-right")[4].append(data.data.moreThan6Months);
                // $(".text-right")[5].append(data.data.overdue);
                var k_data=0;
                for(let k in data.data){
                    if(data.data[k]!=null){
                        k_data+=data.data[k]
                    }
                }
                $(".k-data").html(k_data)

            }else {
                $.alert(data.data);
            }
        },
        error: function () {
        }
    })
}


////////////////////////////////////////////////////////////////////////wll-start////////////////////////////////////////////////////////////////////////
function announcementTableInit() {
    // $table.bootstrapTable({
    //     classes: 'table table-hover table-noborder',
    //     url: '/announcement/pageList',
    //     method: 'post',
    //     //请求内容类型
    //     contentType: "application/x-www-form-urlencoded",
    //     dataType: 'json',        // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
    //     uniqueId: 'id',
    //     idField: 'id',             // 每行的唯一标识字段
    //     toolbar: '#toolbar',       // 工具按钮容器
    //     showColumns: false,         // 是否显示所有的列
    //     showRefresh: false,         // 是否显示刷新按钮
    //     pagination: true,                    // 是否显示分页
    //     sortName: 'updateTm',
    //     sortOrder: "desc",                    // 排序方式
    //     queryParams: function (params) {
    //         var temp = {
    //             pageSize: params.limit,         // 每页数据量
    //             // offset: params.offset,       // sql语句起始索引
    //             pageIndex: (params.offset / params.limit) + 1,
    //             sort: params.sort,           // 排序的列名
    //             sortOrder: params.order,      // 排序方式'asc' 'desc'
    //             searchInfo: $.trim($('#searchInfo').val()),
    //             publicStatus: $('#status-select option:selected').val()
    //         };
    //         return temp;
    //     },                                   // 传递参数
    //     sidePagination: "server",            // 分页方式：client客户端分页，server服务端分页
    //     pageNumber: 1,                       // 初始化加载第一页，默认第一页
    //     pageSize: 5,                        // 每页的记录行数
    //     pageList: [5],
    //     columns: [{
    //         field: 'id',
    //         title: '序号',
    //         width: '6%',
    //         formatter: function (value, row, index) {
    //             return index + 1;
    //         },
    //         rowStyle: {css: {'display': 'inline-block'}}
    //
    //     }, {
    //         field: 'title',
    //         title: '标题',
    //         width: '16%',
    //         formatter: paramsMatter,
    //         cellStyle: {
    //             css: {
    //                 'white-space': 'nowrap',
    //                 'overflow': 'hidden',
    //                 'text-overflow': 'ellipsis',
    //             }
    //         }
    //     }, {
    //         field: 'createPeople',
    //         title: '发布人',
    //         width: '16%',
    //     }, {
    //         field: 'createTm',
    //         title: '发布时间',
    //         width: '16%',
    //         sortable: true,   // 是否排序
    //     }, {
    //         field: 'updatePeople',
    //         title: '最后操作人',
    //         width: '10%',
    //     }, {
    //         field: 'updateTm',
    //         title: '最后操作时间',
    //         width: '16%',
    //         sortable: true,   // 是否排序
    //     }, {
    //         field: 'isTop',
    //         title: '是否置顶',
    //         width: '7%',
    //         formatter: function (value, row, index) {
    //             let is_checked = '';
    //             if (value == 0) {
    //                 is_checked = '';
    //             } else if (value == 1) {
    //                 is_checked = 'checked="checked"';
    //             }
    //             result = '<label class="lyear-switch switch-solid switch-success">' +
    //                 '<input type="checkbox" id="isTop' + row.notifyId + '" ' + is_checked + '>' +
    //                 '<span  onClick="updateStatus(\'' + row.notifyId + '\', \'' + value + '\')"></span>' +
    //                 '</label>';
    //             return result;
    //         },
    //     }, {
    //         field: 'operate',
    //         title: '操作',
    //         width: '22%',
    //         formatter: function (value, row, index) {
    //             let edit = '';
    //             let del = '';
    //             if (row.deleteStatus == 0) {
    //                 del = '<a href="#!" class="btn del-btn" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>';
    //             }
    //             let html = '<a class="js-create-tab btn m-r-10 show-btn" href="#!" data-url="/front/announcement/getAnnouncementDetail?id=' + row.notifyId + '" data-title="公告详情"  title="查看" data-toggle="tooltip"><i class="mdi mdi-eye"></i></a>' + del;
    //             return html;
    //         },
    //         events: {
    //             'click .edit-btn': function (event, value, row, index) {
    //                 $("#recipient-name").val(row.title)
    //             },
    //             'click .del-btn': function (event, value, row, index) {
    //                 delUser(row.notifyId);
    //             },
    //             'click .show-btn': function (event, value, row, index) {
    //
    //             }
    //         }
    //     }
    //     ],
    //     responseHandler: function (result) {
    //         if (result.code == "000000") {
    //             var obj = {
    //                 "rows": result.data,
    //                 "total": result.totalRecords,
    //                 "page": result.totalPages,
    //                 "limit": 1
    //             };
    //         } else {
    //             var obj = {
    //                 "total": 0,
    //                 "rows": [],
    //             }
    //         }
    //         return obj;
    //     },
    //     onLoadSuccess: function (data) {
    //         //表格加载完根据发布状态判断是否置顶列是否显示 0——显示；1——不显示
    //         let publicStatus = $('#status-select option:selected').val();
    //         if (publicStatus == 1) {
    //             $table.bootstrapTable('hideColumn', 'isTop');
    //         } else {
    //             $table.bootstrapTable('showColumn', 'isTop');
    //         }
    //         $("[data-toggle='tooltip']").tooltip()
    //     }
    // });
    //先销毁表格
    $table.bootstrapTable('destroy');
    $table.bootstrapTable({
        classes: 'table table-noborder table-hover',
        url: '/announcement/pageList',
        method: 'post',
        //请求内容类型
        contentType: "application/x-www-form-urlencoded",
        //数据类型
        dataType: "json",
        //是否显示行间隔色
        striped: true,
        //是否启用排序
        sortable: true,
        //排序方式
        sortOrder: "desc",
        sortName: 'createTm',
        //是否使用缓存
        cache: false,
        //显示隐藏列
        showColumns: false,
        //显示刷新按钮
        showRefresh: false,
        //切换显示样式
        showToggle: false,
        //显示Table脚部
        showFooter: false,
        //是否显示分页
        pagination: true,
        //是否显示分页按钮
        showPaginationSwitch: false,
        //是否启用点击选中行
        clickToSelect: false,
        singleSelect: false,
        //最少要显示的列数
        minimumCountColumns: 2,
        //cell没有值时显示
        undefinedText: '-',
        //分页方式：client客户端分页，server服务端分页
        sidePagination: "server",
        //每页的记录行数
        pageSize: 4,
        //初始化加载第1页，默认第1页
        pageNumber: 1,
        //可供选择的每页的行数
        // pageList: "[4]",
        //查询参数
        queryParams: queryParams,
        columns: [
            {title: '主键', field: 'notifyId', visible: false},
            {title: '序号', field: 'index', align: 'left', valign: 'middle', width: '60', formatter: indexFormat},
            {title: '标题', field: 'title', align: 'left', valign: 'middle', formatter: operateFormat},
            {title: '发布人', field: 'createPeople', align: 'left', valign: 'middle'},
            {title: '发布时间', field: 'createTm', align: 'left', valign: 'middle', sortable: true},
            {title: '操作', field: 'operate',title: '操作',width: '12%',
                formatter: function (value, row, index) {
                    if (row.deleteStatus == 0) {
                        let deleteBtn = '<a href="#!" class="btn del-btn" title="删除" data-toggle="tooltip"><i class="mdi mdi-delete"></i></a>';
                        return deleteBtn;
                    }
                },
                events: {
                    'click .del-btn': function (event, value, row, index) {
                        delUser(row.notifyId);
                    },
                }
            }
        ],
        responseHandler: function (result) {
            if (result.code == "000000") {
                var obj = {
                    "rows": result.data,
                    "total": result.totalRecords
                };
            } else {
                var obj = {
                    "total": 0,
                    "rows": [],
                }
            }
            return obj;
        },
        onLoadSuccess: function () {
            //加载成功时执行
            $("[data-toggle='tooltip']").tooltip();
            var status = $('#ggSelect').val();
            if (status == '1') {
                // 已删除
                $table.bootstrapTable('hideColumn', 'operate');
            } else {
                // 已发布
                $table.bootstrapTable('showColumn', 'operate');
            }
        },
        onLoadError: function (status) {
            if (status == 403) {
                alert("权限不足！禁止访问！");
            } else {
                window.location.reload();
                //加载失败时执行
                alert("加载失败！");
            }
        },
        formatLoadingMessage: function () {
            return "请稍等，加载中...";
        }, formatNoMatches: function () {
            return '无符合条件的记录';
        }
    });
}

function indexFormat(value, row, index) {
    return index + 1;
}

function queryParams(params) {
    //搜索条件
    params.searchInfo = $('#searchInfo').val();
    params.publicStatus = $('#ggSelect option:selected').val();
    params.pageSize = params.limit;
    params.pageIndex = (params.offset / params.limit) + 1;
    params.sortName = params.sort; //排序列名
    params.sortOrder = params.order;//排序方式
    return params;
}
function operateFormat(value, row, index) {
    // type = 1 为用户模块-公告查看 没有编辑功能
    let html = '<a class="js-create-tab" href="#!" data-url="/front/announcement/getAnnouncementDetail?id=' + row.notifyId + '">' + value + '</a>';
    // let html = '<a class="js-create-tab" href="#!" data-url="/front/announcement/getAnnouncementDetail?id=' + row.notifyId + '&type=' + 1 + '">' + value + '</a>';
    return html;
}

//发布状态下拉框勾选修改列表状态
function publicStatusChange() {
    $table.bootstrapTable('refreshOptions', {pageNumber: 1, pageList: []});
}

//搜索公告
function searchAnnouncement(text) {
    $table.bootstrapTable('refreshOptions', {pageNumber: 1});
}


//修改置顶状态
function updateStatus(id, state) {
    var newstate = (state == 1) ? 0 : 1; // 发送参数值跟当前参数值相反
    let topInfo = "";
    if (newstate == 1) {
        topInfo = "确定置顶吗？";
    } else {
        topInfo = "确定取消置顶吗？";
    }
    $.alert({
        title: '提示',
        content: topInfo,
        buttons: {
            confirm: {
                text: '确认',
                btnClass: 'btn-primary',
                action: function () {
                    $.ajax({
                        type: "post",
                        //请求内容类型
                        contentType: "application/x-www-form-urlencoded",
                        url: "/announcement/modifyIstop",
                        data: {id: id, isTop: newstate},
                        dataType: 'json',
                        success: function (data, status) {
                            if (data.code == '000000') {
                                $table.bootstrapTable('refresh', data);
                                if (newstate == 1) {
                                    $.alert('置顶成功!');
                                } else {
                                    $.alert('取消置顶成功!');
                                }

                            } else {
                                $table.bootstrapTable('updateCellById', {id: id, field: 'isTop', value: state}); // 因开关点击后样式是变的，失败也重置下
                                $.alert('置顶失败!');
                            }
                        },
                        error: function () {
                            $.alert('修改失败，请稍后再试!');
                            $table.bootstrapTable('updateCellById', {id: id, field: 'isTop', value: state}); // 因开关点击后样式是变的，失败也重置下

                        }
                    });
                }
            },
            cancel: {
                text: '取消',
                action: function () {
                    if (newstate == 1) {
                        $("#isTop" + id).prop('checked', false);
                    } else {
                        $("#isTop" + id).prop('checked', true);
                    }
                }
            }
        }
    });
}
function funRankAchieve(datas) {
        $.ajax({
            type: "post",
            url: "/firstPageController/adminCompanyPerformanceRanking",
            data: {
                dateType:$('#status-select').val()
            },
            dataType: 'json',
            success: function (data, status) {
                if(data.code=="000000"){
                    console.log(data.data,9000);
                    var d_Ranking='';
                    for(let d=0,len=data.data.length;d<len;d++){
                        if(d>4){
                            break;
                        }
                        d_Ranking+=`<div class="b-flex">
                            <div class="r-img"><img src="/images/rankImg-0${d+1}.png" alt=""></div>
<!--                            <div class="r-name-money"><p>${data.data[d].userName}</p> <span>￥ ${data.data[d].contractActualTotalAmount}</span></div>-->
                            <div class="r-company"><span> ${data.data[d].companyName!=null?data.data[d].companyName:''} </span></div>
                            <div class="r-num"><span>￥ ${data.data[d].contractActualTotalAmount == null?0:data.data[d].contractActualTotalAmount}</span></div>
                    </div>`

                    }
                    $(".l-wrap").html(d_Ranking)
                }else{
                    $.alert('失败,查看数据');
                    $(".l-wrap").html('')
                }
            },
            error: function () {
                $.alert('删除失败，请稍后再试!');
                $(".l-wrap").html('')
            }
        });
}
funRankAchieve('');

function ourCompanyInit(){
    $.ajax({
        type: "post",
        url: "/firstPageController/adminCompanyPersonalPerformanceRanking",
        data: {
            dateType:$('#status-select1').val()
        },
        dataType: 'json',
        success: function (data, status) {
            if(data.code=="000000"){
                var d_Ranking='';
                for(let d=0,len=data.data.length;d<len;d++){
                    if(d>4){
                        break;
                    }
                    d_Ranking+=`<div class="b-flex">
                            <div class="r-img"><img src="/images/rankImg-0${d+1}.png" alt=""></div>
<!--                            <div class="r-name-money"><p>${data.data[d].userName}</p> <span>￥ ${data.data[d].contractActualTotalAmount}</span></div>-->
                            <div class="r-company"><span> ${data.data[d].userName!=null?data.data[d].userName:''} </span></div>
                            <div class="r-num"><span>￥ ${data.data[d].contractActualTotalAmount == null?0:data.data[d].contractActualTotalAmount}</span></div>
                    </div>`

                }
                $(".l-wrap1").html(d_Ranking)
            }else{
                $.alert('失败,查看数据');
                $(".l-wrap1").html('')
            }
        },
        error: function () {
            $.alert('删除失败，请稍后再试!');
            $(".l-wrap1").html('')
        }
    });
}


// 操作方法 - 删除
function delUser(id) {
    $.alert({
        title: '提示',
        content: '确定删除吗？',
        buttons: {
            confirm: {
                text: '确认',
                btnClass: 'btn-primary',
                action: function () {
                    $.ajax({
                        type: "get",
                        url: "/announcement/delete",
                        data: {id: id},
                        dataType: 'json',
                        success: function (data, status) {
                            if (data.code == '000000') {
                                $table.bootstrapTable('refresh', data);
                                $.alert('删除成功!');
                            } else {
                                $.alert('删除失败!');
                            }

                        },
                        error: function () {
                            $.alert('删除失败，请稍后再试!');
                        }
                    });
                }
            },
            cancel: {
                text: '取消',
                action: function () {
                }
            }
        }
    });

}

////////////////////////////////////////////////////////////////////////wll-end////////////////////////////////////////////////////////////////////////

// 轮播图
var titleList = [];
var pageNumber;
var swiper = new Swiper('.swiper-container', {
    spaceBetween: 30,
    effect: 'fade',
    loop: true,
    autoplay: true,
    delay: 300,
    pagination: {
        el: '.swiper-pagination',
        clickable: true,
    },

    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
    },
    on: {
        slideChangeTransitionStart: function () {
            var index = Number(this.activeIndex);
            if (index == 4) {
                index = 1
            }
            if (index == 0) {
                index = 3;
            }
            pageNumber = index;
            var title1 = $("#title1").text();
            var title2 = $("#title2").text();
            var title3 = $("#title3").text();
            titleList = [title1, title2, title3];
            document.getElementById('title').innerText = titleList[index - 1];
        }
    },
});

// 轮播图详情
function goDetail() {
    if (titleList[pageNumber - 1]) {
        parent.$(parent.document).data('multitabs').create({
            iframe: true,
            title: '轮播图详情',
            url: "/front/carousel/carouselDetail?id=" + pageNumber
        }, true);
    }
}

var newsListData = [];
var pageIndex = 1;
var pageSize = 6;
var total = 0;
// 获取新闻列表
function getNewsList() {

    $.ajax({
        url: "/NewsController/getNotifyList",
        type: "get",
        dataType: "json",
        data: {
            pageIndex: pageIndex,
            pageSize: pageSize,
            searchInfo: ''
        },
        success: function (data) {
            if (data.code == '000000') {
                $('#newsContent').html(' ');
                total = Math.ceil(data.data.length/pageSize);
                if (data.data.length) {
                    let strNews = '';
                    for (let m=0;m<data.data.length;m++) {
                        /*strNews += '<div style="display: flex;font-size: 12px;line-height: 30px;">\n' +
                        '<div style="flex-grow: 1;width: 60px;">' + data.data[m].title + '</div>\n' +
                        '<div style="flex-grow:1;color: #ccc;">' + data.data[m].createTm + '</div>\n' +
                        '<div class="iconGroup" style="flex-grow: 1;">\n' +
                        '<i class="mdi mdi-eye" id="look' + m + '"><span style="display: none;">' + data.data[m].notifyId + '</span></i>\n' +
                        '<i class="mdi mdi-window-close" id="newsItem' + m + '"><span style="display: none;">' + data.data[m].notifyId + '</span></i>\n' +
                        '</div>\n' +
                        '</div>'*/
                        strNews += '<li>' +
                            '<a href="JavaScript:void(0);" onclick="openNotify(\'' + data.data[m].notifyId +  '\')">' + data.data[m].title + '</a>' +
                            '<span>[' + data.data[m].createTm.substring(0, 10) + ']</span>' +
                            /*'<div class="iconGroup">' +
                            '<a href="JavaScript:void(0);" id="look' + m + '" class="mdi mdi-eye"><span style="display: none;">' + data.data[m].notifyId + '</span></a>' +
                            '<a href="JavaScript:void(0);" id="newsItem' + m + '" class="mdi mdi-window-close"><span style="display: none;">' + data.data[m].notifyId + '</span></a>' +
                            '</div>' +*/
                            '<span class="b-newbook" ><a href="JavaScript:void(0);" onclick="openNotify(\'' + data.data[m].notifyId + '\')">编辑新闻 》</a></span>'+
                            '</li>'
                    }
                    $('#newsContent').append(strNews);
                    $('#newsBox').append(strNews);

                    // 新闻滚动
                    $(".hot-notice").slide({
                        titCell: ".hd ul",
                        mainCell: ".bd ul",
                        autoPage: true,
                        effect:"leftLoop",
                        autoPlay: true,
                        interTime: 3000,
                        scroll: 1,
                        vis: 1
                    });

                    // $('#fenYe').before();
                    /*$('#page').jqPaginator({
                        totalPages: total,
                        visiblePages: 6,
                        currentPage: 1,
                        onPageChange: function (num, type) {
                            if (type == 'change') {
                                pageIndex = num
                                getNewsList()
                            }
                        }
                    });*/
                } else {
                    $('#nothing').css('display', 'block');
                }
            } else {
                $.alert(data.data);
            }
        },
        error: function () {
        }
    })
}

//首页打开新闻详情
function openNotify(notifyId){
    parent.$(parent.document).data('multitabs').create({
        iframe: true,
        title: '新闻详情',
        url: "/front/newsController/getNotifyDetail?id=" + notifyId
    }, true);
}

// 操作方法 - 删除
function delUser1(id) {
    $.alert({
        title: '提示',
        content: '确定删除吗？',
        buttons: {
            confirm: {
                text: '确认',
                btnClass: 'btn-primary',
                action: function () {
                    $.ajax({
                        type: "get",
                        url: "/NewsController/deleteNotify",
                        data: {id: id},
                        dataType: 'json',
                        success: function (data, status) {
                            if (data.code == '000000') {
                                $table.bootstrapTable('refresh', data);
                                $.alert('删除成功!');
                                strNews = '';
                                getNewsList()
                            } else {
                                $.alert('删除失败!');
                            }

                        },
                        error: function () {
                            $.alert('删除失败，请稍后再试!');
                        }
                    });
                }
            },
            cancel: {
                text: '取消',
                action: function () {
                }
            }
        }
    });
}

/*$('body').delegate("[id^=look]",'click',function(){
    window.location.href = '/front/newsController/getNotifyDetail?id=' + $(this).find('span').text()
})*/
$('body').delegate("[id^=newsItem]",'click',function(){
    delUser1($(this).find('span').text())
});


//dateType 数据一览 ""全部  thisMonth 本月 thisLastMonth 上月
// ThisYear 本年
//bs 1 数据一览 全部 本月 上月  2销售简报  本年 本月
function browsDataFun(dateType) {
    // if(dateType=='thisMonth'){
    //     $(".thisMonth").addClass('active')
    //     $(".thisMonth").siblings().removeClass('active')
    // }else if(dateType=='lastMonth'){
    //     $(".thisLastMonth").addClass('active')
    //     $(".thisLastMonth").siblings().removeClass('active')
    // }else if(dateType=='thisLastMonth'){
    //     $(".thisLastMonth").addClass('active')
    //     $(".thisLastMonth").siblings().removeClass('active')
    // }else if(dateType=='thisLastMonth'){
    //     $(".thisLastMonth").addClass('active')
    //     $(".thisLastMonth").siblings().removeClass('active')
    // }else{
    //     $(".thisAll").addClass('active')
    //     $(".thisAll").siblings().removeClass('active')
    // }
    $.ajax({
        type: "post",
        url: "/firstPageController/adminFirstPageContent",
        data: {
            dateType:dateType,
            bs:1
        },
        dataType: 'json',
        success: function (data, status) {

            if(data.code=="000000"){
                // "customerMembershipNumber": 1, //会员数
                //     "contactNumber": 53, //联系人数
                //     "royaltyMoneyTotal": null, //提成总金额
                //     "totalTelehoneHours": 3242, //电话总时长
                //     "opportunityNumber": 20, //商机数
                //     "rankingNumber": 3 //业绩排名
                if(data.data.rankingNumberTrend && data.data.rankingNumberTrend == 1){
                    $('#rankingNumberArrow').addClass(' mdi-arrow-up-bold')
                }else if(data.data.rankingNumberTrend && data.data.rankingNumberTrend == 2){
                    $('#rankingNumberArrow').addClass(' mdi-arrow-down-bold')
                }else{
                    $('#rankingNumberArrow').removeClass(' mdi-arrow-down-bold  mdi-arrow-up-bold')
                }
                if(data.data.customerMembershipNumberTrend && data.data.customerMembershipNumberTrend == 1){
                    $('#customerMembershipNumberArrow').addClass(' mdi-arrow-up-bold')
                }else if(data.data.customerMembershipNumberTrend && data.data.customerMembershipNumberTrend == 2){
                    $('#customerMembershipNumberArrow').addClass(' mdi-arrow-down-bold')
                }else{
                    $('#customerMembershipNumberArrow').removeClass(' mdi-arrow-down-bold  mdi-arrow-up-bold')
                }
                if(data.data.performanceAmountTrend && data.data.performanceAmountTrend == 1){
                    $('#performanceAmountArrow').addClass(' mdi-arrow-up-bold')
                }else if(data.data.performanceAmountTrend && data.data.performanceAmountTrend == 2){
                    $('#performanceAmountArrow').addClass(' mdi-arrow-down-bold')
                }else{
                    $('#performanceAmountArrow').removeClass(' mdi-arrow-down-bold  mdi-arrow-up-bold')
                }
                if(data.data.membershipGrowthRateTrend && data.data.membershipGrowthRateTrend == 1){
                    $('#membershipGrowthRateArrow').addClass(' mdi-arrow-up-bold')
                }else if(data.data.membershipGrowthRateTrend && data.data.membershipGrowthRateTrend == 2){
                    $('#membershipGrowthRateArrow').addClass(' mdi-arrow-down-bold')
                }else{
                    $('#membershipGrowthRateArrow').removeClass(' mdi-arrow-down-bold  mdi-arrow-up-bold')
                }
                if(data.data.membershipRenewalRateTrend && data.data.membershipRenewalRateTrend == 1){
                    $('#membershipRenewalRateArrow').addClass(' mdi-arrow-up-bold')
                }else if(data.data.membershipRenewalRateTrend && data.data.membershipRenewalRateTrend == 2){
                    $('#membershipRenewalRateArrow').addClass(' mdi-arrow-down-bold')
                }else{
                    $('#membershipRenewalRateArrow').removeClass(' mdi-arrow-down-bold  mdi-arrow-up-bold')
                }
                if(data.data.memberTurnoverRateTrend && data.data.memberTurnoverRateTrend == 1){
                    $('#memberTurnoverRateArrow').addClass(' mdi-arrow-up-bold')
                }else if(data.data.memberTurnoverRateTrend && data.data.memberTurnoverRateTrend == 2){
                    $('#memberTurnoverRateArrow').addClass(' mdi-arrow-down-bold')
                }else{
                    $('#memberTurnoverRateArrow').removeClass(' mdi-arrow-down-bold  mdi-arrow-up-bold')
                }
                $("#rankingNumber").html(data.data.rankingNumber || 0);
                $("#customerMembershipNumber").html(data.data.customerMembershipNumber || 0);
                $("#performanceAmount").html(data.data.performanceAmount || 0);
                $("#membershipGrowthRate").html((data.data.membershipGrowthRate || 0) + '<em>%</em>');
                $("#membershipRenewalRate").html((data.data.membershipRenewalRate || 0) + '<em>%</em>');
                $("#memberTurnoverRate").html((data.data.memberTurnoverRate || 0) + '<em>%</em>');

            }else{
                $.alert('失败,查看数据');
            }
        },
        error: function () {
            $.alert('失败');
        }
    });
}
browsDataFun('');
//销售简报
function addmentFun(dateType) {
    if(dateType=='ThisYear'){
        $(".a-ThisYear").addClass('active');
        $(".a-ThisYear").siblings().removeClass('active')
    }else{
        $(".a-thisMonth").addClass('active');
        $(".a-thisMonth").siblings().removeClass('active')
    }
    $.ajax({
        type: "post",
        url: "/firstPageController/firstPageContent",
        data: {
            dateType:dateType,
            bs:2
        },
        dataType: 'json',
        success: function (data, status) {
            if(data.code=="000000"){
                $("#addAchievementNumber").html(data.data.addAchievementNumber);
                $("#addFollowVisitNumber").html(data.data.addFollowVisitNumber);
                $("#addOrderNumber").html(data.data.addOrderNumber)
            }else{
                $.alert('失败,查看数据');
            }
        },
        error: function () {
            $.alert('删除失败，请稍后再试!');
        }
    });
}
addmentFun('thisMonth');

$.ajax({
    type: "post",
    url: "/firstPageController/adminPerformanceTrend",

    dataType: 'json',
    success: function (data, status){
        if(data.code=='000000'){
            let xAxisData=[],yAxisData=[],yAxisData_last=[];
            xAxisData=data.data.thisTime;
            yAxisData=data.data.thisPerformance;
            yAxisData_last=data.data.lastPerformance;
            line_option.xAxis[0].data = xAxisData;
            line_option.series[0].data = yAxisData;

            line_option.series[1].data = yAxisData_last;
            myChart.setOption(line_option);
        }

    },
    error: function (){}
});
//echarts 折线图

var eLine=document.getElementById("e-line");
let myChart = echarts.init(eLine);
const color = ['#6A8ED8', '#1BC8B4'];
var line_option={
    // backgroundColor: '#fff',
    tooltip: {
        trigger: 'axis',
        extraCssText: 'font-size:14px;line-height:24px;color:#567;background:#fff;padding:luck-table10px;box-shadow:0 0 3px rgba(0, 0, 0, 0.2)',
        formatter: function(params) {
            let html = '';
            params.forEach(v => {
                html += `<div><span style="display:inline-block;color: #999999;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${color[v.componentIndex]};"></span>${v.seriesName}:业绩<span style="color:${color[v.componentIndex]};font-size:18px;font-weight:700;padding-left: 10px;">${v.value}</span>`
            });
            return html
        }
    },

    xAxis: [{
        show: true,
        type: 'category',
        axisLine: {
            show: true,
            lineStyle:{
                color:'rgba(83, 83, 83,0.1)',
            }

        },
        axisTick:{//坐标轴刻度相关设置。
            show: false,
        },
        splitArea: {
            // show: true,
            color: '#f00',
            lineStyle: {
                color: '#f00'
            },
        },
        axisLabel: {
            color: '#999999'
        },
        splitLine: {
            show: false
        },
        boundaryGap: false,
        data: [],

    }],
    grid: {
        x: '8%',
        y: '5%',
        x2: '5%',
        y2: '5%',
        borderWidth: 1
    },
    yAxis: [{
        type: 'value',
        min: 0,
        // max: 140,
        splitNumber: 4,
        splitLine: {
            show: true,
            lineStyle: {
                //坐标轴在 grid 区域中的分隔线。
                color: 'rgba(83, 83, 83,0.1)'
            }
        },
        axisLine: {
            //坐标轴轴线相关设置
            show: false,
        },
        axisLabel: {
            show: true,
            textStyle: {
                color: '#999999',
            },
        },
        axisTick: {
            show: false,
        },
    }],
    series: [{
        name: '本年',
        type: 'line',
        smooth: true, //是否平滑
        showAllSymbol: false,
        symbol: 'circle',
        symbolSize: 2,
        lineStyle: {
            normal: {
                color: "#6A8ED8",
            },
        },
        itemStyle: {
            color: "#6A8ED8",
        },
        areaStyle: {
            normal: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                    offset: 0,
                    color: 'rgba(106, 142, 216, .5)'
                },
                    {
                        offset: 1,
                        color: 'rgba(106, 142, 216,0)'
                    }
                ], false),
                shadowColor: 'rgba(106, 142, 216, 0.9)',
                shadowBlur: 20
            }
        },
        data: [ ]
    },
        {
            name: '去年',
            type: 'line',
            smooth: true, //是否平滑
            showAllSymbol: false,
            symbol: 'circle',
            symbolSize: 2,
            lineStyle: {
                normal: {
                    color: "#1BC8B4",
                },
            },
            itemStyle: {
                color: "#1BC8B4",
            },
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: 'rgba(27, 200, 180, .5)'
                    },
                        {
                            offset: 1,
                            color: 'rgba(27, 200, 180,0)'
                        }
                    ], false),
                    shadowColor: 'rgba(27, 200, 180, 0.9)',
                    shadowBlur: 20
                }
            },
            data: [ ]
        },

    ]
};

function goEdit() {
    parent.$(parent.document).data('multitabs').create({
        iframe: true,
        title: '编辑轮播图',
        url: "/front/carousel/editCarousel"
    }, true);
}
